import sys
from appium.webdriver.common.mobileby import MobileBy

sys.path.append("..")   # 找不到APPAuToTest目录的话  就用sys.path.append("..")
from APPAuToTest.base.BasePage import BasePage
import time


# 登录page
class LoginPage(BasePage):
    # 元素定位
    agree = (MobileBy.ID, "com.zhengnengliang.precepts:id/btn_ok")
    my = (MobileBy.ID, "com.zhengnengliang.precepts:id/tabButton4")
    clickLogin = (MobileBy.ID, "com.zhengnengliang.precepts:id/tv_user_name")
    phone = (MobileBy.ID, "com.zhengnengliang.precepts:id/edit_phone")
    pwd = (MobileBy.ID, "com.zhengnengliang.precepts:id/edit_password")
    loginBtn = (MobileBy.ID, "com.zhengnengliang.precepts:id/tv_login")

    def login(self, admin, password):
        time.sleep(2)
        self.click(self.agree)
        time.sleep(2)
        self.click(self.my)
        time.sleep(2)
        self.click(self.clickLogin)
        time.sleep(2)
        self.sendkeys(self.phone, admin)
        time.sleep(2)
        self.sendkeys(self.pwd, password)
        time.sleep(2)
        self.click(self.loginBtn)
